Technotes


Opening the Serial Driver



Technote DV 11August 1989



Revised by: Sriram Subramanian December 1989
Written by: Sriram Subramanian August 1989

This Technical Note describes the recommended, safe, and compatible way to open the Macintosh serial driver, and it explains why you should no longer check for port availability.

Changes since October 1989: Corrected syntax errors in the sample code.


Starting with the 128K ROM, we recommend that applications do not check the low-memory globals SPConfig, PortAUse, and PortBUse before opening the serial driver. It is no longer the application's responsibility to test for the availability of the serial ports. When running AppleTalk Phase 2, it is now possible to use the printer port for asynchronous serial communication while AppleTalk is active and using an alternate connection, such as EtherTalk or TokenTalk.

The serial driver automatically verifies that the serial port is correctly configured and free for an asynchronous driver; if it is not correctly configured or free, the serial driver returns either the result code portNotCf or portInUse. The serial driver already has all the code built into it for testing the availability of the serial ports before trying to complete the _Open call. Therefore, since all of the required checks are made inside the driver itself, we recommend that a simple OpenDriver call be made when you need to use a serial port.

By using just the OpenDriver call to the serial driver, you ensure that your code is both user-friendly and compatible with future versions of the System Software.

Pascal

result := OpenDriver('.AOut',AoutRefNumber);  {Check result codes in a real application. }

result := OpenDriver('.AIn',AinRefNumber); {See failure mechanism in Sample Code. }

C

result = OpenDriver("\p.AOut",&AoutRefNumber); /*Check result codes in a real app.*/

result = OpenDriver("\p.AIn",&AinRefNumber); /* See failure mechanism in Sample Code.*/

If you must maintain compatibility with the 64K ROMs, call _SysEnvirons, then either call RAMSDOpen for the 64K ROM machines or OpenDriver for the others.


Further Reference:


Technotes
Previous Technote | Contents | Next Technote